package com.atguigu.ssyx.mq.service;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * ClassName: RabbitService
 * Package: com.atguigu.ssyx.mq.service
 * Description:
 *
 * @Author: 比特张
 * @Create: 2023/7/17 - 9:24
 * @Version: v1.0
 */
@Service
public class RabbitService {
    //  引入操作rabbitmq 的模板
    @Resource
    private RabbitTemplate rabbitTemplate;

    /**
     * @param exchange   交换机
     * @param routingKey 路由
     * @param message    消息
     * @return true
     */
    public boolean sendMessage(String exchange, String routingKey, Object message) {
        rabbitTemplate.convertAndSend(exchange, routingKey, message);
        return true;
    }

}









